<!DOCTYPE html>
<html lang="zh-CN">
<head>
    {{template "widgets/head.html" .}}

    <link href="{{$.StaticDomain}}/static/webuploader/webuploader.css" rel="stylesheet">
    <link href="{{$.StaticDomain}}/static/cropper/2.3.4/cropper.min.css" rel="stylesheet">
</head>
<body>
<div class="manual-reader">
    {{template "widgets/header.html" .}}
    <div class="container manual-body">
        <div class="row">

            {{template "setting/menu.html" .}}

            <div class="page-right">
                <div class="m-box">
                    <div class="box-head">
                        <strong class="box-title">二维码管理</strong>
                    </div>
                </div>
                <div class="box-body">
                    <div class="help-block">每一个认真的人，都值得被认真对待！</div>
                    <div class="help-block">每一个热心分享知识的人，都值得被打赏！</div>
                    <div class="help-block">在这里，您可以上传您的 <strong>支付宝收款二维码</strong> 和 <strong>微信收款二维码</strong> 来接收读者们的赞助，书栈不会从中拿您一分钱。</div>
                    <div class="help-block">您的二维码将会在您分享文档的介绍页面中的打赏按钮功能里面展示。</div>
                    <div class="help-block">分享，让知识传承更久远！书栈(BookStack.CN)，与您同在！</div>
                </div>
                <div class="col-xs-6 col-sm-4">
                    <h3>支付宝收款二维码</h3>
                    <div class="help-block">点击图片上传或更新您的二维码</div>
                    <div>
                        <img class="border qrcode-pay qrcode-alipay img-responsive" data-paytype="alipay" src="{{if .Qrcode.Alipay}}{{$.OssDomain}}/{{.Qrcode.Alipay}}{{else}}/static/images/plus-o.png{{end}}" alt="支付宝二维码">
                    </div>
                </div>
                <div class="col-xs-6 col-sm-4">
                    <h3>微信收款二维码</h3>
                    <div class="help-block">点击图片上传或更新您的二维码</div>
                    <div>
                        <img class="border qrcode-pay qrcode-wxpay img-responsive"  data-paytype="wxpay" src="{{if .Qrcode.Wxpay}}{{$.OssDomain}}/{{.Qrcode.Wxpay}}{{else}}/static/images/plus-o.png{{end}}" alt="微信支付二维码">
                    </div>
                </div>

                <form id="pay-form" target="notarget"  action="" style="display: none;" method="post" enctype="multipart/form-data">
                    <input type="hidden" name="paytype">
                    <input type="file" name="qrcode" accept="image/png,image/jpeg,image/gif">
                </form>
            </div>

        </div>
    </div>
</div>


<iframe src="" style="display: none;" name="notarget" id="notarget" frameborder="0"></iframe>

{{/*<script src="/static/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>*/}}
<script src="//apps.bdimg.com/libs/jquery/1.11.3/jquery.min.js" type="text/javascript"></script>
{{/*<script src="/static/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>*/}}
<script src="//apps.bdimg.com/libs/bootstrap/3.3.4/js/bootstrap.min.js" type="text/javascript"></script>
<script src="{{$.StaticDomain}}/static/js/toast.script.js" type="text/javascript"></script>
<script src="/static/js/main.js" type="text/javascript"></script>
<script>
    $(function () {
        $(".qrcode-pay").click(function(){
           $("#pay-form [name=paytype]").val($(this).attr("data-paytype"));
            $("#pay-form input[type=file]").trigger("click");
        });

        //change事件处理
        $("#pay-form input[type=file]").change(function () {
            if($(this).val()){
                $("#pay-form").submit();
            }
        });

        $("#notarget").load(function () {
            var obj=JSON.parse($(this).contents().find('body').text());
            console.log(obj);
            if(obj.errcode==0){
                alertTips("success","上传成功",2000,"");
                setTimeout(function () {
                    location.reload();
                },1500)
            }else{
                alertTips("danger",obj.message,3000,"");
            }
        });
    });
</script>
</body>
</html>